package com.jm.offer.easy;

/**
 * @Description https://leetcode-cn.com/problems/da-yin-cong-1dao-zui-da-de-nwei-shu-lcof/
 * @date 2022/4/10 7:42
 */
public class _17打印从1到最大n位数 {

    public static void main(String[] args) {
        printNumbers(9);

    }

    public static int[] printNumbers(int n) {
        if (n >= 10){
            n = 9;
        }
        int tmp = 1;
        int len = 0;
        for (int i = 0; i < n; i++) {
            len += tmp * 9;
            tmp = tmp * 10;
        }
        int[] arr = new int[len];
        int j = 1;
        for (int i = 0; i < arr.length; i++) {
            arr[i] = j;
            j++;
        }
        return arr;
    }
}
